<?php include _include(APP_PATH.'view/htm/header_thread.inc.htm');?>

<!--{hook user_login_start.htm}-->

<div class="ModalManager modal fade in show d-block">
    <div class="Modal modal-dialog LogInModal Modal--small">
        <div class="Modal-content" style="margin-top: -52px">
            <div class="Modal-close App-backControl">
                <button class="Button Button--icon Button--link hasIcon win-back" type="button">
                    <i class="icon fa fa-times Button-icon"></i>
                </button>
            </div>
            <div class="ajax_modal_body">
                <form action="<?php echo url('user-login');?>" method="post" id="form">
                    <div class="Modal-header">
                        <h3 class="App-titleControl App-titleControl--text"><?php echo lang('user_login');?></h3>
                        <!--{hook user_login_title_after.htm}-->
                    </div>
                    <!-- <div class="Modal-alert">
                        <div class="Alert Alert--error">
                            <span class="Alert-body">好像不能进行此操作</span>
                        </div>
                    </div> -->
                    <div class="Modal-body">
                        <div class="LogInButtons">
                            <a href="qq_login.htm" class="Button LogInButton--qq LogInButton hasIcon" role="button" title="QQ 登录" target="_blank">
                                <i class="icon fa fa-fw fa-qq Button-icon"></i>
                                <span class="Button-label">QQ 登录</span>
                            </a>
                        </div>
                        <div class="Form Form--centered">
                            <div class="Form-group">
                                <input class="FormControl" type="text" placeholder="<?php echo lang('email');?> / <?php echo lang('username');?>" id="email" name="email">
                                <div class="invalid-feedback"></div>
                            </div>
                            <!--{hook user_login_email_after.htm}-->

                            <div class="Form-group">
                                <input class="FormControl" type="password" placeholder="<?php echo lang('password');?>" id="password" name="password">
                                <div class="invalid-feedback"></div>
                            </div>
                            <!--{hook user_login_password_after.htm}-->

                            <!-- <div class="Form-group text-left">
                                <div class="custom-control custom-checkbox">
                                    <input type="checkbox" class="custom-control-input" id="user-login">
                                    <label class="custom-control-label" for="user-login">记住我</label>
                                </div>
                            </div> -->
                            <div class="Form-group mt-2">
                                <button class="Button Button--primary Button--block" type="submit" id="submit" data-loading-text="<?php echo lang('submiting');?>...">
                                    <span class="Button-label"><?php echo lang('login');?></span>
                                </button>
                            </div>
                            <!--{hook user_login_submit_after.htm}-->

                        </div>
                    </div>
                    <div class="Modal-footer">
                        <!--{hook user_login_form_footer_right_start.htm}-->
                        <p class="LogInModal-signUp">还没有注册？<a href="<?php echo url('user-create');?>"><?php echo lang('user_create');?></a></p>
                        <?php if(!empty($conf['user_resetpw_on'])) { ?>
                        <p class="LogInModal-forgotPassword"><a href="<?php echo url('user-resetpw');?>">忘记了密码？</a></p>
                        <?php } ?>
                        <!--{hook user_login_form_footer_right_end.htm}-->
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!--{hook user_login_end.htm}-->

<?php include _include(APP_PATH.'view/htm/footer.inc.htm');?>

<script src="<?php echo $conf['view_url'];?>js/md5.js"></script>

<script>
var jform = $('#form');
var jsubmit = $('#submit');
var jemail = $('#email');
var jpassword = $('#password');
var referer = '<?php echo $referer;?>';
jform.on('submit', function() {
    jform.reset();
    jsubmit.button('loading');
    var postdata = jform.serializeObject();
    postdata.password = $.md5(postdata.password);
    $.xpost(jform.attr('action'), postdata, function(code, message) {
        if(code == 0) {
            jsubmit.button(message).delay(1000).location(referer);
        } else if(xn.is_number(code)) {
            alert(message);
            jsubmit.button('reset');
        } else {
            jform.find('[name="'+code+'"]').alert(message).focus();
            jsubmit.button('reset');
        }
        /*
        if(code == 0) {
            jsubmit.button(message).delay(1000).location(referer);
        } else if(code == 'email') {
            jemail.alert(message).focus();
            jsubmit.button('reset');
        } else if(code == 'password') {
            jpassword.alert(message).focus();
            jsubmit.button('reset');
        } else {
            alert(message);
            jsubmit.button('reset');
        }*/
    });
    return false;
});

</script>

<!--{hook user_login_js.htm}-->